.class public final Lcom/burstly/lib/util/Signature;
.super Ljava/lang/Object;
.source "Signature.java"


# static fields
.field protected static final LOG:Lcom/burstly/lib/util/LoggerExt; = null

.field private static final LOG_TAG:Ljava/lang/String; = "Signature"


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 33
    invoke-static {}, Lcom/burstly/lib/util/LoggerExt;->getInstance()Lcom/burstly/lib/util/LoggerExt;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/util/Signature;->LOG:Lcom/burstly/lib/util/LoggerExt;

    return-void
.end method

.method private constructor <init>()V
    .locals 0

    .prologue
    .line 43
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 44
    return-void
.end method

.method public static getSignature(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    .locals 8
    .parameter "data"
    .parameter "key"

    .prologue
    .line 55
    :try_start_0
    const-string v6, "HmacSHA1"

    invoke-static {v6}, Ljavax/crypto/Mac;->getInstance(Ljava/lang/String;)Ljavax/crypto/Mac;

    move-result-object v4

    .line 56
    .local v4, mac:Ljavax/crypto/Mac;
    new-instance v5, Ljavax/crypto/spec/SecretKeySpec;

    invoke-virtual {p1}, Ljava/lang/String;->getBytes()[B

    move-result-object v6

    const-string v7, "HmacSHA1"

    invoke-direct {v5, v6, v7}, Ljavax/crypto/spec/SecretKeySpec;-><init>([BLjava/lang/String;)V

    .line 57
    .local v5, secret:Ljavax/crypto/spec/SecretKeySpec;
    invoke-virtual {v4, v5}, Ljavax/crypto/Mac;->init(Ljava/security/Key;)V

    .line 58
    invoke-virtual {p0}, Ljava/lang/String;->getBytes()[B

    move-result-object v6

    invoke-virtual {v4, v6}, Ljavax/crypto/Mac;->doFinal([B)[B

    move-result-object v0

    .line 59
    .local v0, digest:[B
    new-instance v3, Ljava/math/BigInteger;

    const/4 v6, 0x1

    invoke-direct {v3, v6, v0}, Ljava/math/BigInteger;-><init>(I[B)V

    .line 60
    .local v3, hash:Ljava/math/BigInteger;
    const/16 v6, 0x10

    invoke-virtual {v3, v6}, Ljava/math/BigInteger;->toString(I)Ljava/lang/String;

    move-result-object v2

    .line 61
    .local v2, enc:Ljava/lang/String;
    invoke-virtual {v2}, Ljava/lang/String;->length()I

    move-result v6

    rem-int/lit8 v6, v6, 0x2

    if-eqz v6, :cond_0

    .line 62
    new-instance v6, Ljava/lang/StringBuilder;

    invoke-direct {v6}, Ljava/lang/StringBuilder;-><init>()V

    const-string v7, "0"

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 64
    :cond_0
    const-string v6, "-"

    const-string v7, ""

    invoke-virtual {v2, v6, v7}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;
    :try_end_0
    .catch Ljava/security/NoSuchAlgorithmException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/security/InvalidKeyException; {:try_start_0 .. :try_end_0} :catch_1

    move-result-object v6

    .line 72
    .end local v0           #digest:[B
    .end local v2           #enc:Ljava/lang/String;
    .end local v3           #hash:Ljava/math/BigInteger;
    .end local v4           #mac:Ljavax/crypto/Mac;
    .end local v5           #secret:Ljavax/crypto/spec/SecretKeySpec;
    :goto_0
    return-object v6

    .line 66
    :catch_0
    move-exception v1

    .line 67
    .local v1, e:Ljava/security/NoSuchAlgorithmException;
    sget-object v6, Lcom/burstly/lib/util/Signature;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v7, "Signature"

    invoke-virtual {v6, v7, v1}, Lcom/burstly/lib/util/LoggerExt;->logThrowable(Ljava/lang/String;Ljava/lang/Throwable;)V

    .line 72
    .end local v1           #e:Ljava/security/NoSuchAlgorithmException;
    :goto_1
    const-string v6, ""

    goto :goto_0

    .line 69
    :catch_1
    move-exception v1

    .line 70
    .local v1, e:Ljava/security/InvalidKeyException;
    sget-object v6, Lcom/burstly/lib/util/Signature;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v7, "Signature"

    invoke-virtual {v6, v7, v1}, Lcom/burstly/lib/util/LoggerExt;->logThrowable(Ljava/lang/String;Ljava/lang/Throwable;)V

    goto :goto_1
.end method
